package com.ysqcould.web.controller.allocation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ysqcould.allocation.domain.Navigation;
import com.ysqcould.allocation.service.INavigationService;

/**
 * 首页导航栏名称Controller
 * 
 * @author jcd
 * @date 2022-09-19
 */
@RestController
@RequestMapping("/allocation/navigation")
public class NavigationController extends BaseController
{
    @Autowired
    private INavigationService navigationService;

    /**
     * 查询首页导航栏名称列表
     */
    @PreAuthorize("@ss.hasPermi('allocation:navigation:list')")
    @GetMapping("/list")
    public TableDataInfo list(Navigation navigation)
    {
        startPage();
        List<Navigation> list = navigationService.selectNavigationList(navigation);
        return getDataTable(list);
    }

    /**
     * 导出首页导航栏名称列表
     */
    @PreAuthorize("@ss.hasPermi('allocation:navigation:export')")
    @Log(title = "首页导航栏名称", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Navigation navigation)
    {
        List<Navigation> list = navigationService.selectNavigationList(navigation);
        ExcelUtil<Navigation> util = new ExcelUtil<Navigation>(Navigation.class);
        util.exportExcel(response, list, "首页导航栏名称数据");
    }

    /**
     * 获取首页导航栏名称详细信息
     */
    @PreAuthorize("@ss.hasPermi('allocation:navigation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(navigationService.selectNavigationById(id));
    }

    /**
     * 新增首页导航栏名称
     */
    @PreAuthorize("@ss.hasPermi('allocation:navigation:add')")
    @Log(title = "首页导航栏名称", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Navigation navigation)
    {
        return toAjax(navigationService.insertNavigation(navigation));
    }

    /**
     * 修改首页导航栏名称
     */
    @PreAuthorize("@ss.hasPermi('allocation:navigation:edit')")
    @Log(title = "首页导航栏名称", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Navigation navigation)
    {
        return toAjax(navigationService.updateNavigation(navigation));
    }

    /**
     * 删除首页导航栏名称
     */
    @PreAuthorize("@ss.hasPermi('allocation:navigation:remove')")
    @Log(title = "首页导航栏名称", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(navigationService.deleteNavigationByIds(ids));
    }

    @Log(title = "修改导航栏状态",businessType = BusinessType.UPDATE)
    @PutMapping("changeStatus")
    public AjaxResult changeStatus(@RequestBody Navigation navigation){
        return toAjax(navigationService.updateNavigationStatus(navigation));
    }
}
